Skip to content

Fix pointer tests on 64-bit hosts - #28

Open
Firat17aze wants to merge 1 commit into
MaJerle:developfrom
Firat17aze:fix-portable-pointer-tests
Open

Firat17aze wants to merge 1 commit into
MaJerle:developfrom
Firat17aze:fix-portable-pointer-tests

Conversation

@Firat17aze

Copy link
Copy Markdown

Problem

The pointer-format tests hard-code 32-bit output. On a 64-bit host where the compiler cannot use the suite's GCC-only -m32 path, %p correctly emits 16 hexadecimal digits and all three pointer assertions fail.

Fix

Select the expected pointer width from UINTPTR_MAX. The existing 32-bit expectations remain unchanged, while 64-bit hosts now check the leading-zero padding produced for a full-width pointer.

Validation

  • Reproduced on arm64 macOS with AppleClang: 148 passed, 3 pointer tests failed before the change.
  • cd tests && python3 test.py --github: 151 passed, 0 failed after the change.
  • git diff --check: passed.
  • No hardware testing was run because this changes host-side test expectations only.

LLMs were used for review and code generation in some parts of this pull request.

@by-ae by-ae left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this locally with native 64-bit GCC. I had to comment out set(LWPRINTF_TEST_ARCH 32) in tests/test_basic/cmake.cmake for that, because without gcc-multilib the forced -m32 doesn't link:

  • develop (920135e): 158 passed, 3 failed, all of them the %p cases
  • this branch: 151 passed, 0 failed
  • this branch merged into current develop (merges cleanly): 161 passed, 0 failed

The 64-bit expectations match what case 'p' does in lwprintf.c, zero-padded to sizeof(uintptr_t) * 2 digits. <stdint.h> is already included at the top of test_basic.c, so UINTPTR_MAX is defined there and the #if can't quietly fall back to the 32-bit branch.

One thing: cmake.cmake still sets LWPRINTF_TEST_ARCH 32, and the workflow installs gcc-multilib, so CI builds with -m32 and only ever runs the #else branch. The new 64-bit expectations only run in local builds: the Win64-Debug preset, a non-GCC compiler like the AppleClang run in the description, or GCC with that line removed. Now that the test handles both widths, it may be worth dropping set(LWPRINTF_TEST_ARCH 32) (and the comment above it) so the native GCC job covers the 64-bit path. Or keep it and add a second test config without it, if you want both widths checked in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants